var oldObjArrayExpress = new Array();
var setoldObjArrayExpress = new Array();
//////////////Start Check Out Express Page ////////////////
function getReservationRoomManageMentCheckOutExpress(data){
	clearData();
	waitingDialog({});
	var searchName = $("#SearchAll_allPage").val();
	if($("#RowpagerCheckOutExpressListRoomManageMent").val() == null){
		getCurrentTabData().lineExpress = 10;
	}else{
		getCurrentTabData().lineExpress = $("#RowpagerCheckOutExpressListRoomManageMent").val();
	}
	if($("#pagerCheckOutExpressListRoomManageMent").val() == null){
		var pagePointer = 1;
	}else{
		var pagePointer = $("#pagerCheckOutExpressListRoomManageMent").val(); 
	}
	var offfset = (getCurrentTabData().lineExpress*pagePointer)-getCurrentTabData().lineExpress;
	var dataOld =  $("#typeCheckReservationExpressCheckout").val();
	var valueDateCheckin = $("#calendar_btw_checkinFolioPending").attr("dateofBtwCheckinFolioPending");
	var valueDateCheckout = $("#calendar_btw_checkoutFolioPending").attr("dateofBtwCheckoutFolioPending");
	if(valueDateCheckin!=""&&valueDateCheckout!=""){
		var dateCheckin = $("#calendar_btw_checkinFolioPending").attr("dateofBtwCheckinFolioPending");
	  	var dateCheckout = $("#calendar_btw_checkoutFolioPending").attr("dateofBtwCheckoutFolioPending");
	  	$("#calendar_btw_checkinFolioPending").val($.datepicker.parseDate("yy-mm-dd",dateCheckin).getFormatedString());
		$("#calendar_btw_checkoutFolioPending").val($.datepicker.parseDate("yy-mm-dd",dateCheckout).getFormatedString());
		$('#calendar_btw_checkinFolioPending').attr('dateofBtwCheckinFolioPending',dateCheckin);
		$('#calendar_btw_checkoutFolioPending').attr('dateofBtwCheckoutFolioPending',dateCheckout);
		getCurrentTabData().valueDateCheckin = dateCheckin;
		getCurrentTabData().valueDateCheckout = dateCheckout;
	}else{
		/*var dateCheckin = new Date().toSystemFormat();
		var dateCheckout= new Date().toSystemFormat();
		$("#calendar_btw_checkinFolioPending").val($.datepicker.parseDate("yy-mm-dd",dateCheckin).getFormatedString());
		$("#calendar_btw_checkoutFolioPending").val($.datepicker.parseDate("yy-mm-dd",dateCheckout).getFormatedString());*/
	/*	$('#calendar_btw_checkinFolioPending').attr('dateofBtwCheckinFolioPending',dateCheckin);
		$('#calendar_btw_checkoutFolioPending').attr('dateofBtwCheckoutFolioPending',dateCheckout);
		getCurrentTabData().valueDateCheckin = dateCheckin;
		getCurrentTabData().valueDateCheckout = dateCheckout;*/
	}
	if(data=="CheckOutExpressListRoomManageMent"){
		typeReservationExpressFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data=="G"){
		getCurrentTabData().typeReservationExpress = data;
		typeReservationExpressFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data=="S"){
		getCurrentTabData().typeReservationExpress = data;
		typeReservationExpressFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data=="A"){
		getCurrentTabData().typeReservationExpress = data;
		typeReservationExpressFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data == "dateSearch"){
		var dataOld =  $("#typeCheckReservationExpressCheckout").val();
		var valueDateCheckin = $("#calendar_btw_checkinFolioPending").attr("dateofBtwCheckinFolioPending");
		var valueDateCheckout = $("#calendar_btw_checkoutFolioPending").attr("dateofBtwCheckoutFolioPending");
		if(valueDateCheckin!=""&&valueDateCheckout!=""){
			var dateCheckin = $("#calendar_btw_checkinFolioPending").attr("dateofBtwCheckinFolioPending");
			getCurrentTabData().valueDateCheckin = valueDateCheckin;
			getCurrentTabData().valueDateCheckout = valueDateCheckout;
			var dateCheckout= $("#calendar_btw_checkoutFolioPending").attr("dateofBtwCheckoutFolioPending");
			if(dataOld=="G"){
				getCurrentTabData().typeReservationExpress = dataOld;
				if(pagePointer>1){
					var link = "/reservationService?func=getReservationExpressCheckOutGroup&offset="
						+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					var linkSet = "/reservationService?func=getReservationExpressCheckOutGroup&offset="
						+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					getCurrentTabData().linkSet = linkSet;
					simpleservice(link,null,showDataResRoomManageMentSetCountExpress,getCurrentTabData().lineExpress);
				}else{
					getCurrentTabData().beforePageExpress = ""; 
					getCurrentTabData().beforeSubPageExpress = "";
					var link = "/reservationService?func=getReservationExpressCheckOutGroup&offset="
						+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					simpleservice(link,null,showDataResRoomManageMentCheckOutExpress,data);
				}
			}else if(dataOld=="S"){
				getCurrentTabData().typeReservationExpress = dataOld;
				if(pagePointer>1){
					var link = "/reservationService?func=getReservationExpressCheckOutSingle&offset="
						+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					var linkSet = "/reservationService?func=getReservationExpressCheckOutSingle&offset="
						+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					getCurrentTabData().linkSet = linkSet;
					simpleservice(link,null,showDataResRoomManageMentSetCountExpress,getCurrentTabData().lineExpress);
				}else{
					getCurrentTabData().beforePageExpress = ""; 
					getCurrentTabData().beforeSubPageExpress = "";
					var link = "/reservationService?func=getReservationExpressCheckOutSingle&offset="
						+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					simpleservice(link,null,showDataResRoomManageMentCheckOutExpress,data);
				}
			}else if(dataOld=="A"){
				getCurrentTabData().typeReservationExpress = dataOld;
				if(pagePointer>1){
					var link = "/reservationService?func=getReservationExpressCheckOut&offset="
						+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					var linkSet = "/reservationService?func=getReservationExpressCheckOut&offset="
						+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					getCurrentTabData().linkSet = linkSet;
					simpleservice(link,null,showDataResRoomManageMentSetCountExpress,getCurrentTabData().lineExpress);
				}else{
					getCurrentTabData().beforePageExpress = ""; 
					getCurrentTabData().beforeSubPageExpress = "";
					var link = "/reservationService?func=getReservationExpressCheckOut&offset="
						+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					simpleservice(link,null,showDataResRoomManageMentCheckOutExpress,data);
				}
			}
		}else{
			$("#calendar_btw_checkinFolioPending").select();
		}
	}
}
function showDataResRoomManageMentCheckOutExpress(data,output){
	var valueDateCheckin = getCurrentTabData().valueDateCheckin;
	var valueDateCheckout = getCurrentTabData().valueDateCheckout;
	if((valueDateCheckin!=""&&valueDateCheckout!="")&&(valueDateCheckin!=undefined&&valueDateCheckout!=undefined)){
		var dateCheckin = valueDateCheckin;
	  	var dateCheckout = valueDateCheckout;
	  	$("#calendar_btw_checkinFolioPending").val($.datepicker.parseDate("yy-mm-dd",dateCheckin).getFormatedString());
		$("#calendar_btw_checkoutFolioPending").val($.datepicker.parseDate("yy-mm-dd",dateCheckout).getFormatedString());
		$('#calendar_btw_checkinFolioPending').attr('dateofBtwCheckinFolioPending',dateCheckin);
		$('#calendar_btw_checkoutFolioPending').attr('dateofBtwCheckoutFolioPending',dateCheckout);
	}
	// set for pager
	getCurrentTabData().tablePager = "tablepagingExpress";
	getCurrentTabData().pagerNumberField = "pagerCheckOutExpressListRoomManageMent";
	getCurrentTabData().functionGetData = "getReservationRoomManageMentCheckOutExpress";
	getCurrentTabData().pageName = "CheckOutExpressListRoomManageMent";
	getCurrentTabData().pageNavPosition = "pageNavPositionExpress";
	getCurrentTabData().trCheck = "trExpress";
	if(getCurrentTabData().checkinExpress!=undefined){
		$('#calendar_btw_checkinFolioPending').val($.datepicker.parseDate("yy-mm-dd",getCurrentTabData().checkinExpress).getFormatedString());
		$('#calendar_btw_checkoutFolioPending').attr('dateofBtwCheckinFolioPending',getCurrentTabData().checkinExpress);
	}
	if(getCurrentTabData().checkoutExpress!=undefined){
		$('#calendar_btw_checkinFolioPending').val($.datepicker.parseDate("yy-mm-dd",getCurrentTabData().checkoutExpress).getFormatedString());
		$('#calendar_btw_checkoutFolioPending').attr('dateofBtwCheckoutFolioPending',getCurrentTabData().checkoutExpress);
	}
	if(getCurrentTabData().typeReservationExpress!=undefined){
		$('#typeCheckReservationExpressCheckout option[value='+getCurrentTabData().typeReservationExpress+']').attr('selected', 'selected');
	}
	if(data.trim()=="[]"){
		var textDataEmpty = '<tr clearTr="expressCheckoutReservation" >'+
		'<td colspan="100%" style="text-align:center;" >'+
		dataEmpty+
		'</td>'+
		'</tr>';
		textExpressCheckOut = textDataEmpty;
		$("[clearTr=expressCheckoutReservation]").remove();
		$("#CheckOutExpressListRoomManageMent_Id_Tr").replaceWith("<tr id=CheckOutExpressListRoomManageMent_Id_Tr ></tr>"+textExpressCheckOut);
		textExpressCheckOut = '';
	}else{
			$("[clearTr=expressCheckoutReservation]").remove();
		var objArray = new Array();
		if((data=="textSearch"||data=="G"||data=="S"||data=="A")&&data!="dateSearch"){
			objArray 	= oldObjArrayExpress;
			objArray[0] = objArray;
		}else{
			objArray 	= JSON.parse(data);
			oldObjArrayExpress = objArray;
			objArray = objArray[0];
		}
		var numberSet = getCurrentTabData().beforePageExpress; 
		var numberSubSet = getCurrentTabData().beforeSubPageExpress;
		sortIdRoommanagement(objArray);
		textExpressCheckOutPrint = '';
			var checkBgColor = 0;
			var countGroup = 0;
			var OldGroupId =0;
			var valueSearch = "";
			var firstSelect = "";
			var folioId = "";
			var typeReservation = $("#typeCheckReservationExpressCheckout").val();
			var emailPic = '<img src=../images/components/roommanagement/email.png alt=Note height=15 width=20>';
			var printPci = '<img src=../images/components/roommanagement/print.png alt=Note height=15 width=20>';
			for(var i =0;i<objArray.length;i++){
			//	if(objArray[i].folioId!=null&&objArray[i].folioId!=""){
					if(objArray[i].folioId!=null&&objArray[i].folioId!="")
						folioId = objArray[i].folioId;
					else
						folioId="-"
					if(objArray[i].name!=""&&objArray[i].name!=undefined){
						var nameReservation = objArray[i].name.split(" ");
					}else{
						var nameReservation = "";
					}
					var Objtitle = objArray[i].reservationTitle;
					var ObjgroupId = objArray[i].groupId;
					var ObjId = objArray[i].id;
					var checkContinue = checkedFilter(output,valueSearch,nameReservation,firstSelect,Objtitle,ObjgroupId,typeReservation,ObjId)
					if(checkContinue==1){
						continue;
					}
					if(objArray[i].groupId!="0"){
						if(objArray[i].subList!=undefined){
							//	OldGroupId = objArray[i].groupIdString;
								var setDateFormat = new Date(objArray[i].date);
								var setFateFormatCheckout = setDateFormat.addDate(objArray[i].span);
								groupId = objArray[i].groupIdString;
								var splitResIdInGroup = objArray[i].resList.split(",");
								var textSubRes = "";
								var textSubResPrint = "";
								var checkBgColorG =0;
								var StatusResInGroup = "";
								var folioId_inGroup = "";
								for(var subRes = 0;subRes<objArray[i].subList.length;subRes++){
									if(objArray[i].subList[subRes].folioId!=null&&objArray[i].subList[subRes].folioId!="")
										folioId_inGroup = objArray[i].subList[subRes].folioId;
									else
										folioId_inGroup = "-";
									var setDateFormatRes = new Date(objArray[i].subList[subRes].date);
									var setDateFormatCheckoutRes = setDateFormatRes.addDate(objArray[i].subList[subRes].span);
									var ShowNameGuest = "";
									/// Name Empty
									if(objArray[i].subList[subRes].name!=undefined){
										ShowNameGuest = objArray[i].subList[subRes].name
									}
									///
									if(objArray[i].subList[subRes].reservationTitle=="Reserved Rooms"){
										StatusResInGroup = statusResv;
									}else if(objArray[i].subList[subRes].reservationTitle=="Checked-out Rooms"){
										StatusResInGroup = statusCheckOut;
									}else if(objArray[i].subList[subRes].reservationTitle=="Temp Rooms"){
										StatusResInGroup = statusTempResv;
									}else if(objArray[i].subList[subRes].reservationTitle=="Cancel Reservation"){
										StatusResInGroup = statusCancelCheckin;
									}else{
										StatusResInGroup = statusCheckin;
									}
									if(checkBgColorG==0){
										statusRecord = 'dataRecordBot';
										checkBgColorG = 1;
									}else{
										statusRecord = 'dataRecordBot';
										checkBgColorG = 0;
									}
									var showDisplayGuestname = "";
									if(ShowNameGuest==""){
										showDisplayGuestname = '<tr clearTr=expressCheckoutReservation class="'+statusRecord+'" onclick="if(linkClick==true)noGuestName();"  id="btnEditS" >';
									}else{
										showDisplayGuestname = '<tr clearTr=expressCheckoutReservation class="'+statusRecord+'" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].subList[subRes].id+')"  id="btnEditS" >';
									}
									var chargeFolio = "";
									var paidFolio = "";
									var balance = "";
									if(objArray[i].subList[subRes].chargeFolio!=undefined)
										chargeFolio = toCurrencyString(objArray[i].subList[subRes].chargeFolio);
									if(objArray[i].subList[subRes].paidFolio!=undefined)
										paidFolio = toCurrencyString(objArray[i].subList[subRes].paidFolio);
									if(objArray[i].subList[subRes].balance!=undefined)
										balance = toCurrencyString(objArray[i].subList[subRes].balance)
										var runnumberSub = "";
									if(getCurrentTabData().beforePageExpress!=undefined&&getCurrentTabData().beforePageExpress!=""){
										runnumberSub = (numberSet+1)+"."+(subRes+1);
									}else{
										runnumberSub = (i+1)+"."+(subRes+1);
									}
									textSubRes += showDisplayGuestname+
										'<td  class="spanDataRight">'+
										runnumberSub+
										'</td>'+
										'<td class="spanDataCenter">' +
											'<span>'+objArray[i].subList[subRes].id+'</span>'+
										'</td>'+
										'<td class="spanDataCenter">' +
										'</td>'+
										'<td class="spanDataCenter">'+
											'<span class="guestName" >'+ShowNameGuest+'</span>'+
										'</td>'+
										'<td class="spanDataCenter">'+
											'<span>'+setDateFormatRes.getFormatedString()+'-'+setDateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].subList[subRes].span+'</span>'+
										'</td>'+
										'<td class="spanDataCenter"> '+
											'<span>'+objArray[i].subList[subRes].roomTypeName+'('+objArray[i].subList[subRes].roomName+')'+'</span>'+
										'</td>'+
										'<td class="spanDataCenter">' +
											folioId_inGroup+
										'</td>'+
										'<td class="spanDataCenter">'+
											'<span>'+chargeFolio+'</span>'+
										'</td>'+
										'<td class="spanDataCenter">'+
											'<span>'+paidFolio+'</span>'+
										'</td>'+
										'<td class="spanDataCenter">'+
											'<span><div class="fongwordwarp" >'+balance+'</div></span>'+
										'</td>'+
										'</tr>';
									textSubResPrint += '<tr clearTr="expressCheckoutReservation" class="dataRecord" onclick="if(linkClick&&ShowNameGuest!="") CallEditReservedPageWithLoadElement(id,'+objArray[i].subList[subRes].id+')"  id="btnEditS" >'+
										'<td  class="spanDataRight">'+
										runnumberSub+
										'</td>'+
										'<td class="spanDataCenter">' +
											'<span>'+objArray[i].subList[subRes].id+'</span>'+
										'</td>'+
										'<td class="spanDataCenter">' +
										'</td>'+
										'<td class="spanDataCenter">'+
											'<span class="guestName" >'+ShowNameGuest+'</span>'+
										'</td>'+
										'<td class="spanDataCenter">'+
											'<span>'+setDateFormatRes.getFormatedString()+'-'+setDateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].subList[subRes].span+'</span>'+
										'</td>'+
										'<td class="spanDataCenter"> '+
											'<span>'+objArray[i].subList[subRes].roomTypeName+'('+objArray[i].subList[subRes].roomName+')'+'</span>'+
										'</td>'+
										'<td class="spanDataCenter">' +
											
										'</td>'+
										'<td class="spanDataCenter">'+
											'<span>'+chargeFolio+'</span>'+
										'</td>'+
										'<td class="spanDataCenter">'+
											'<span>'+paidFolio+'</span>'+
										'</td>'+
										'<td class="spanDataCenter">'+
											'<span><div class="fongwordwarp" >'+balance+'</div></span>'+
										'</td>'+
										'</tr>';
								}
								///Check StatusGroup
									for(var resCount = 0; resCount<objArray[i].subList.length;resCount++){
										if(getStatusResInGroup=="Reserved Rooms"){
											checkStatusResInGroup++;
										}else if(getStatusResInGroup=="Checked-out Rooms"){
											checkStatusCheckoutResInGroup++;
										}else if(getStatusResInGroup=="Temp Rooms"){
											checkStatusResInGroup++;
										}else if(getStatusResInGroup=="Cancel Reservation"){
											checkStatusResInGroup++;
										}else{
											checkStatusCheckInResInGroup++;
										}
										if(checkStatusCheckInResInGroup>0&&checkStatusResInGroup==0){
											showStatusResInGroup = statusCheckin;
											checkStatusResInGroup = 0;
											checkStatusCheckoutResInGroup = 0;
										}else if(checkStatusResInGroup>0){
											showStatusResInGroup = statusCheckinNoFull;
											checkStatusResInGroup = 0;
											checkStatusCheckoutResInGroup = 0;
										}
									}
								///
									var chargeFolioGroup = "";
									var paidFolioGroup = "";
									var balanceGroup = "";
									if(objArray[i].chargeFolio!=undefined)
										chargeFolioGroup = objArray[i].chargeFolio;
									if(objArray[i].paidFolio!=undefined)
										paidFolioGroup = objArray[i].paidFolio;
									if(objArray[i].balance!=undefined)
										balanceGroup = objArray[i].balance;
									if(getCurrentTabData().beforePageExpress!=undefined&&getCurrentTabData().beforePageExpress!=""){
										numberSet = numberSet+1;
										number = numberSet;
									}else{
										number = (i+1);
									}
									textExpressCheckOut += '<tr clearTr="expressCheckoutReservation" class="dataRecordGroup" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].groupIdString+')"  id="btnEditG" >'+
									'<td class="spanDataCenter">'+
									number+'(<span id=groupCount'+objArray[i].groupIdString+' >'+objArray[i].resList.split(",").length+'</span>)'+
									'</td>'+
									'<td class="spanDataCenter">'+
										'<span>G'+objArray[i].groupIdString+'</span>'+
									'</td>'+
									'<td class="spanDataCenter">' +
										'<span></span>'+
									'</td>'+
									'<td class="spanDataCenter">'+
										'<span class="ownerName" >'+objArray[i].name+'</span>'+
									'</td>'+
									'<td class="spanDataCenter">'+
										'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
									'</td>'+
									'<td class="spanDataCenter"> '+
									'</td>'+
									'<td class="spanDataCenter">' +
										folioId+
									'</td>'+
									'<td class="spanDataCenter">'+
										'<span>'+chargeFolioGroup+'</span>'+
									'</td>'+
									'<td class="spanDataCenter">'+
										'<span>'+paidFolioGroup+'</span>'+
									'</td>'+	
									'<td class="spanDataCenter">'+
										'<span><div class="fongwordwarp" >'+balanceGroup+'</div></span>'+
									'</td>'+
									'</tr>'+textSubRes;
									textExpressCheckOutPrint += '<tr clearTr="expressCheckoutReservation" class="dataRecordGroup" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].groupIdString+')"  id="btnEditG" >'+
									'<td class="spanDataCenter">'+
									number+'(<span id=groupCount'+objArray[i].groupIdString+' >'+objArray[i].resList.split(",").length+'</span>)'+
									'</td>'+
									'<td class="spanDataCenter">'+
										'<span>G'+objArray[i].groupIdString+'</span>'+
									'</td>'+
									'<td class="spanDataCenter">' +
										'<span></span>'+
									'</td>'+
									'<td class="spanDataCenter">'+
										'<span class="ownerName" >'+objArray[i].name+'</span>'+
									'</td>'+
									'<td class="spanDataCenter">'+
										'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
									'</td>'+
									'<td class="spanDataCenter"> '+
									'</td>'+
									'<td class="spanDataCenter">' +
										folioId+
									'</td>'+
									'<td class="spanDataCenter">'+
										'<span>'+chargeFolioGroup+'</span>'+
									'</td>'+
									'<td class="spanDataCenter">'+
										'<span>'+paidFolioGroup+'</span>'+
									'</td>'+
									'<td class="spanDataCenter">'+
										'<span><div class="fongwordwarp" >'+balanceGroup+'</div></span>'+
									'</td>'+
									'</tr>'+textSubResPrint;
						}else{
							if(objArray[i].folioId!=null&&objArray[i].folioId!="")
								folioId_inGroup = objArray[i].folioId;
							else
								folioId_inGroup = "-";
							var setDateFormatRes = new Date(objArray[i].date);
							var setDateFormatCheckoutRes = setDateFormatRes.addDate(objArray[i].span);
							var ShowNameGuest = "";
							/// Name Empty
							if(objArray[i].name!=undefined){
								ShowNameGuest = objArray[i].name
							}
							///
							if(objArray[i].reservationTitle=="Reserved Rooms"){
								StatusResInGroup = statusResv;
							}else if(objArray[i].reservationTitle=="Checked-out Rooms"){
								StatusResInGroup = statusCheckOut;
							}else if(objArray[i].reservationTitle=="Temp Rooms"){
								StatusResInGroup = statusTempResv;
							}else if(objArray[i].reservationTitle=="Cancel Reservation"){
								StatusResInGroup = statusCancelCheckin;
							}else{
								StatusResInGroup = statusCheckin;
							}
							if(checkBgColorG==0){
								statusRecord = 'dataRecordBot';
								checkBgColorG = 1;
							}else{
								statusRecord = 'dataRecordBot';
								checkBgColorG = 0;
							}
							var showDisplayGuestname = "";
							if(ShowNameGuest==""){
								showDisplayGuestname = '<tr clearTr=expressCheckoutReservation class="'+statusRecord+'"   id="btnEditS" >';
							}else{
								showDisplayGuestname = '<tr clearTr=expressCheckoutReservation class="'+statusRecord+'" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')"  id="btnEditS" >';
							}
							var chargeFolio = "";
							var paidFolio = "";
							var balance = "";
							if(objArray[i].chargeFolio!=undefined)
								chargeFolio = toCurrencyString(objArray[i].chargeFolio);
							if(objArray[i].paidFolio!=undefined)
								paidFolio = toCurrencyString(objArray[i].paidFolio);
							if(objArray[i].balance!=undefined)
								balance = toCurrencyString(objArray[i].balance)
							var runnumberSub = "";
							
							if(getCurrentTabData().beforePageExpress!=undefined&&getCurrentTabData().beforePageExpress!=""){
								runnumberSub = (numberSet)+"."+(numberSubSet);
								numberSubSet = numberSubSet+1;
							}else{
								runnumberSub = (i+1)+"."+(subRes+1);
							}
							textExpressCheckOut += showDisplayGuestname+
								'<td  class="spanDataRight">'+
								runnumberSub+
								'</td>'+
								'<td class="spanDataCenter">' +
									'<span>'+objArray[i].id+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">' +
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span class="guestName" >'+ShowNameGuest+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+setDateFormatRes.getFormatedString()+'-'+setDateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].span+'</span>'+
								'</td>'+
								'<td class="spanDataCenter"> '+
									'<span>'+objArray[i].roomTypeName+'('+objArray[i].roomName+')'+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">' +
									folioId_inGroup+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+chargeFolio+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+paidFolio+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span><div class="fongwordwarp" >'+balance+'</div></span>'+
								'</td>'+
								'</tr>';
							textExpressCheckOutPrint += '<tr clearTr="expressCheckoutReservation" class="dataRecord" onclick="if(linkClick&&ShowNameGuest!="") CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')"  id="btnEditS" >'+
								'<td  class="spanDataRight">'+
								runnumberSub+
								'</td>'+
								'<td class="spanDataCenter">' +
									'<span>'+objArray[i].id+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">' +
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span class="guestName" >'+ShowNameGuest+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+setDateFormatRes.getFormatedString()+'-'+setDateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].span+'</span>'+
								'</td>'+
								'<td class="spanDataCenter"> '+
									'<span>'+objArray[i].roomTypeName+'('+objArray[i].roomName+')'+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">' +
									
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+chargeFolio+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+paidFolio+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span><div class="fongwordwarp" >'+balance+'</div></span>'+
								'</td>'+
								'</tr>';
						}
					}else{
						res = objArray[i].id;
						var setDateFormat = new Date(objArray[i].date);
						var setFateFormatCheckout = setDateFormat.addDate(objArray[i].span);
						getStatusResInGroup = objArray[i].reservationTitle;
						if(getStatusResInGroup=="Reserved Rooms"){
							showStatusResInGroup = statusResv;
						}else if(getStatusResInGroup=="Checked-out Rooms"){
							showStatusResInGroup = statusCheckOut;
						}else if(getStatusResInGroup=="Temp Rooms"){
							showStatusResInGroup = statusTempResv;
						}else if(getStatusResInGroup=="Cancel Reservation"){
							showStatusResInGroup = statusCancelCheckin;
						}else{
							showStatusResInGroup = statusCheckin;
						}
						if(checkBgColorG==0){
							statusRecord = 'dataRecordBot';
							checkBgColorG = 1;
						}else{
							statusRecord = 'dataRecordBot';
							checkBgColorG = 0;
						}
						if(setDateFormat.getFormatedString()!=undefined){
							var chargeFolioS = "";
							var paidFolioS = "";
							var balanceFolioS = "";
							
							if(objArray[i].chargeFolio)
								chargeFolioS = toCurrencyString(objArray[i].chargeFolio);
							if(objArray[i].paidFolio)
								paidFolioS = toCurrencyString(objArray[i].paidFolio);
							if(objArray[i].balance)
								balanceFolioS = toCurrencyString(objArray[i].balance);
							if(getCurrentTabData().beforePageExpress!=undefined&&getCurrentTabData().beforePageExpress!=""){
								numberSet = numberSet+1;
								number = numberSet;
							}else{
								number = (i+1);
							}
							textExpressCheckOut += '<tr clearTr="expressCheckoutReservation" class="'+statusRecord+'" onclick="if(linkClick){ CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')}" id="btnEditS" >'+
								'<td class="spanDataCenter">'+
								number+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+objArray[i].id+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">' +
									'<span></span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span class="guestName" >'+objArray[i].name+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
								'</td>'+
								'<td class="spanDataCenter"> '+
									'<span>'+objArray[i].roomTypeName+'('+objArray[i].roomName+')'+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">' +
										folioId+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+chargeFolioS+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+paidFolioS+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span><div class="fongwordwarp" >'+balanceFolioS+'</div></span>'+
								'</td>'+
								'</tr>';
								textExpressCheckOutPrint += '<tr clearTr="expressCheckoutReservation" class="dataRecord" onclick="if(linkClick){ CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')}" id="btnEditS" >'+
								'<td class="spanDataCenter">'+
								number+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+objArray[i].id+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">' +
									'<span></span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span class="guestName" >'+objArray[i].name+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
								'</td>'+
								'<td class="spanDataCenter"> '+
									'<span>'+objArray[i].roomTypeName+'('+objArray[i].roomName+')'+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">' +
								
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+chargeFolioS+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span>'+paidFolioS+'</span>'+
								'</td>'+
								'<td class="spanDataCenter">'+
									'<span><div class="fongwordwarp" >'+balanceFolioS+'</div></span>'+
								'</td>'+
								'</tr>';
						}
					}
				//}
			}
			if(textExpressCheckOut==""){
				var textDataEmpty = '<tr clearTr="expressCheckoutReservation" >'+
				'<td colspan="100%" style="text-align:center;" >'+
				dataEmpty+
				'</td>'+
				'</tr>';
				textExpressCheckOut = textDataEmpty;	
			}
			$("#CheckOutExpressListRoomManageMent_Id_Tr").replaceWith("<tr id= CheckOutExpressListRoomManageMent_Id_Tr ></tr>"+textExpressCheckOut);
			textPrint = textExpressCheckOutPrint;
			textExpressCheckOut = "";
			textSubRes = "";
	}
	dateRoomManageMent({checkin:"calendar_btw_checkinFolioPending",atrcheckin:"dateofBtwCheckinFolioPending"},{checkout:"calendar_btw_checkoutFolioPending",atrcheckout:"dateofBtwCheckoutFolioPending"});
	$(".ui-datepicker-trigger").css("margin-top","2px");
	closeWaitingDialog();
	showDataResRoomManageMentSetPageExpress(data,getCurrentTabData().lineExpress);
}

function showDataResRoomManageMentSetPageExpress(data,output){
	$("[clearTr*=expressReservationPage]").remove();
	objArray = JSON.parse(data);
	objArray = objArray[1];
	debugger;
	
	var textRoomPendingCheckinSetpage = "";
	for(var i =0;i<objArray.length;i++){
		var textSubRes = "";
		if(objArray[i].groupId!="0"){
			var statusRecord = "";
			for(var subRes = 0;subRes<objArray[i].subList.length;subRes++){
				textSubRes += '<tr clearTr=expressReservationPage  ><td></td></tr>';
			}
			textRoomPendingCheckinSetpage += '<tr clearTr=expressReservationPage class="trExpress"><td></td></tr>'+textSubRes;
		}else{
			textRoomPendingCheckinSetpage += '<tr clearTr=expressReservationPage ><td></td></tr>';
		}
	}
	$("[name = CheckOutExpressListRoomManageMent_Id_Tr2]").replaceWith("<tr name=CheckOutExpressListRoomManageMent_Id_Tr2></tr>"+textRoomPendingCheckinSetpage);
	textRoomPendingCheckinSetpage = "";
	textSubRes = "";
	
	showPager(output);
}

function showDataResRoomManageMentSetCountExpress(data,output){
	var subCount = 0;
	var recCount = 0;
	var objArray = new Array();
	if((data=="textSearch"||data=="G"||data=="S"||data=="A"||data=="reservationType_A"||data=="Checked-out Rooms"||data=="Checked-in Rooms")&&data!="dateSearch"){
		objArray = oldObjArrayExpress;
		objArrayCheck = objArray[0];
		objArray = objArray[1];
	}else{
		objArray = JSON.parse(data);
		oldObjArrayExpress = objArray;
		objArrayCheck = objArray[0];
		objArray = objArray[1];
	}
	setoldObjArrayExpress = objArray;
	sortIdRoommanagement(objArray);
	sortIdRoommanagement(objArrayCheck);
	for(var i =0;i<objArray.length;i++){
		if(objArray[i].groupId!="0"){
			if(objArray[i].subList!=undefined){
				if(objArrayCheck[objArrayCheck.length-1].groupId==objArray[i].groupId){
					recCount = (i+1);
					subCount = objArrayCheck[objArrayCheck.length-1].subList.length+1;
					break;
				}
			}else{
				if(objArrayCheck[objArrayCheck.length-1].groupId==objArray[i].groupId){
					recCount = (i+1);
					break;
				}
			}
		}else{
			if(objArrayCheck[objArrayCheck.length-1].id==objArray[i].id){
				recCount = (i+1);
				break;
			}
		}
	}
	getCurrentTabData().beforePageExpress = (recCount);
	getCurrentTabData().beforeSubPageExpress = subCount;
	simpleservice(getCurrentTabData().linkSet,null,showDataResRoomManageMentCheckOutExpress,data);
}

function typeReservationExpressFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName){
	var valueDateCheckin = getCurrentTabData().valueDateCheckin;
	var valueDateCheckout = getCurrentTabData().valueDateCheckout;
	if((valueDateCheckin!=""&&valueDateCheckout!="")&&(valueDateCheckin!=undefined&&valueDateCheckout!=undefined)){
		if(dataOld=="G"){
			getCurrentTabData().typeReservationExpress = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationExpressCheckOutGroup&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationExpressCheckOutGroup&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountExpress,getCurrentTabData().lineExpress);
			}else{
				getCurrentTabData().beforePageExpress = ""; 
				getCurrentTabData().beforeSubPageExpress = "";
				var link = "/reservationService?func=getReservationExpressCheckOutGroup&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomManageMentCheckOutExpress,data);
			}
		}else if(dataOld=="S"){
			getCurrentTabData().typeReservationExpress = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationExpressCheckOutSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationExpressCheckOutSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountExpress,getCurrentTabData().lineExpress);
			}else{
				getCurrentTabData().beforePageExpress = ""; 
				getCurrentTabData().beforeSubPageExpress = "";
				var link = "/reservationService?func=getReservationExpressCheckOutSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomManageMentCheckOutExpress,data);
			}
		}else if(dataOld=="A"){
			getCurrentTabData().typeReservationExpress = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationExpressCheckOut&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationExpressCheckOut&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountExpress,getCurrentTabData().lineExpress);
			}else{
				getCurrentTabData().beforePageExpress = ""; 
				getCurrentTabData().beforeSubPageExpress = "";
				var link = "/reservationService?func=getReservationExpressCheckOut&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomManageMentCheckOutExpress,data);
			}
		}
	}else{
		if(dataOld=="G"){
			getCurrentTabData().typeReservationExpress = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationExpressCheckOutGroup&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+(pagePointer-1)+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationExpressCheckOutGroup&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountExpress,getCurrentTabData().lineExpress);
			}else{
				getCurrentTabData().beforePageExpress = ""; 
				getCurrentTabData().beforeSubPageExpress = "";
				var link = "/reservationService?func=getReservationExpressCheckOutGroup&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomManageMentCheckOutExpress,data);
			}
		}else if(dataOld=="S"){
			getCurrentTabData().typeReservationExpress = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationExpressCheckOutSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+(pagePointer-1)+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationExpressCheckOutSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountExpress,getCurrentTabData().lineExpress);
			}else{
				getCurrentTabData().beforePageExpress = ""; 
				getCurrentTabData().beforeSubPageExpress = "";
				var link = "/reservationService?func=getReservationExpressCheckOutSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomManageMentCheckOutExpress,data);
			}
		}else if(dataOld=="A"){
			getCurrentTabData().typeReservationExpress = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationExpressCheckOut&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+(pagePointer-1)+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationExpressCheckOut&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountExpress,getCurrentTabData().lineExpress);
			}else{
				getCurrentTabData().beforePageExpress = ""; 
				getCurrentTabData().beforeSubPageExpress = "";
				var link = "/reservationService?func=getReservationExpressCheckOut&offset="
					+offfset+"&line="+getCurrentTabData().lineExpress+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomManageMentCheckOutExpress,data);
			}
		}
	}
}
//////////////End Check Out Express Page /////////